package org.dreamwork.jasmine2.annotation;

import org.dreamwork.jasmine2.ajax.RequestMethod;
import org.dreamwork.util.DefaultConverter;
import org.dreamwork.util.IConverter;

import java.lang.annotation.*;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 2010-12-10
 * Time: 14:47:17
 */
@Target (ElementType.METHOD)
@Retention (RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface AjaxMethod {
    boolean support () default true;
    String contentType () default "text/plain;charset=UTF-8";

    /**
     * the encoding charset using by the request and the response
     * @return the charset
     */
    String charset () default "utf-8";

    /**
     * The class what used to convert the method result to String
     * @return the class of the converter
     */
    Class<? extends IConverter> converter () default DefaultConverter.class;

    /**
     * HTTP method
     * @return HTTP method
     */
    RequestMethod method () default RequestMethod.GET;
    boolean noCache () default true;

    /**
     * wrap the result to struct: {"status":"ok|fail", "cause":"string"} if set to true
     * @return wrap the result or not
     */
    boolean wrapResult () default true;
    boolean rawData () default false;

    /**
     * rewrite the URL pattern
     * @return the url pattern
     */
    String pattern () default "";

    /**
     * mapping to the URL
     * @return the url mapping
     */
    String mapping () default "";
}
